public class Singleton {
    private Singleton(){}
    private static int instanceCount = 1;
    public static Singleton getInstance() throws SingletonException{
        if(Singleton.instanceCount==1){
           Singleton.instanceCount--;
           return new Singleton();
        }else {
           throw new SingletonException("You cannot have more than one instance");
        }
    }
}
class SingletonException extends Exception{
    public SingletonException(String message){
        super(message);
    }
}
